import os
import time
from concurrent.futures.process import ProcessPoolExecutor
from multiprocessing import Manager

def put_data(q):
    count=0
    while True:
        if q.qsize()<50:
            for i in range(200):
                data=f'----{os.getpid()}----{count}---{i}'
                q.put(data)
                print(f"添加数据：{data}")
            count+=1
            time.sleep(1)
def get_data(q):
    while True:
        if q.qsize()>=10:
            for i in range(20):
                data=q.get()
                print(f'消费数据：{data}')
        else:
            time.sleep(2)

def main():
    que=Manager().Queue()
    with ProcessPoolExecutor(max_workers=6) as pool:
        pool.submit(put_data,que)
        for i in range(5):
            pool.submit(get_data,que)

if __name__ == '__main__':
   main()
